<template>
   <div>
    <el-form-item :label='label' label-width='120px' prop='attr'>
      <el-upload class='oss-upload' ref='upload' action=''
        :multiple='true'
        :file-list="attr"
        :on-remove='handleRemove'
        :on-change='handleChange'
        :auto-upload='false'>
        <el-button slot='trigger' size='small' type='primary'>选取文件</el-button>
        <!-- <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">上传到服务器</el-button> -->
        <!-- <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div> -->
      </el-upload>
    </el-form-item>
   </div>
</template>
<script>
export default {
  computed: {
  
  },
  props:["attr", "label"],
  data() {
    return {
      uploadVisible: true,
    };
  },
  created() {
  },
  mounted() {

  },
  methods: {
    closeBox() {
      this.uploadVisible = false;
      this.$ge.$emit("upload-form-files-close-finish");
    },
    cancel() {
      this.uploadVisible = false;
    },
    handleRemove(file, fileList) {
      this.attr = fileList;
    },
    handleChange(file, fileList) {
      //类型（jpg, png）和大小(2M 以内)
      // const isJPG = file.raw.type === 'image/jpeg' || file.raw.type === 'image/png';
      const isLt2M = file.raw.size / 1024 / 1024 < 500;
      // if (!isJPG) {
      //     this.$message.error('上传头像图片只能是 jpg 或者 png 格式!');
      //     return;
      // }
      if (!isLt2M) {
          this.$message.error('单个文件大小不能超过 500MB!');
          return;
      }
      // if(isJPG && isLt2M) {
      //   this.fileList.push(file);
      // }
      this.attr = fileList;
      return false;
    },
  },
};
</script>

<style lang="scss">

</style>
